<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register page</title>

<script type="text/javascript" >
var xmlhttp;
function checkUser() {
	var name = document.getElementById("uname").value;  
	createRequest("../AccountIsExistServlet?account=" + name);
}
function createRequest(url) {
	xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');  
	xmlhttp.open("get", url, false);  
    xmlhttp.send(null);
   	xmlhttp.onreadystatechange = getResult();
}
function getResult() {
	console.log("status:" + xmlhttp.readyState);
    if(xmlhttp.readyState == 4){//Ajax引擎状态为成功
        if(xmlhttp.status == 200){//HTTP协议状态为成功
        	alert("恭喜您，用户名可以使用。 ");
        }else{
            alert("请求失败，错误码=" + xmlHttp.status);
        }
    }
}
</script>
</head>
<body>
	<table align="center" width="300" border="1" height="150">
		<tr>
			<td colspan="3" align="center">
				<b>register page</b>
			</td>
		</tr>
		<tr>
			<td align="right">username：</td>
			<td><input type="text" name="uname" id="uname"/></td>
			<td><button onclick="checkUser()">check username</button></td>
		</tr>
		<tr>
			<td colspan="3" align="center">
				<input type="submit">
			</td>
		</tr>
	</table>
</body>
</html>